package cos.android.tim;

import cos.android.tim.utils.Utils;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;

public class SelectWorld extends Activity implements OnClickListener {

	Button world1;
	Button world2;
	Button back;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);

		setContentView(R.layout.selectworld);

		world1 = (Button) findViewById(R.id.world1Button);
		world2 = (Button) findViewById(R.id.world2Button);
		back = (Button) findViewById(R.id.backButton);

		world1.setOnClickListener(this);
		world2.setOnClickListener(this);
		back.setOnClickListener(this);

	}

	@Override
	protected void onResume() {
		super.onResume();

		// Interfaz de este menu

	}

	@Override
	public void onClick(View v) {

		Intent i = null;
		i = new Intent(this, SelectLevel.class);
		switch (v.getId()) {

		case (R.id.world1Button):
			i.putExtra("world", 1);
			break;
		case (R.id.world2Button):
			i.putExtra("world", 2);
			break;
		case (R.id.backButton):
			i = new Intent(this, InitScreen.class);
		}
		startActivity(i);
		finish();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		super.onCreateOptionsMenu(menu);

		menu.add(Menu.NONE, Utils.MENU_BACK, Menu.NONE, R.string.backInitStr);
		menu.add(Menu.NONE, Utils.MENU_EXIT, Menu.NONE, R.string.salirStr);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case Utils.MENU_BACK:
			Intent i = new Intent(this, InitScreen.class);
			startActivity(i);
			finish();
			return true;

		case Utils.MENU_EXIT:
			finish();
			return true;
		}
		return false;
	}

}
